﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ECONTACT.Bussiness;
using ECONTACT.DataLayer;
using System.Data;
using System.Windows.Forms;
using DevComponents.DotNetBar.Controls;
using DevComponents.Editors.DateTimeAdv;

namespace ECONTACT.Controller
{
    public class NamHocCtrl
    {
        NamHocData m_NamHocData = new NamHocData();

        #region Hien thi ComboBox
        public void HienThiComboBox(ComboBoxEx comboBox)
        {
            comboBox.DataSource = m_NamHocData.LayDsNamHoc();
            comboBox.DisplayMember = "MaNH";
            comboBox.ValueMember = "MaNH";
        }
        public void HienThiComboBoxTen(ComboBoxEx comboBox)
        {
            comboBox.DataSource = m_NamHocData.LayDsNamHoc();
            comboBox.DisplayMember = "TenNH";
            comboBox.ValueMember = "MaNH";
        }
        #endregion

        #region Do du lieu vao DataGridView

        public void HienThi(DataGridViewX dGV,
                            TextBoxX txtMaNH,
                            TextBoxX txtTenNH)
        {
            BindingSource bS = new BindingSource();
            bS.DataSource = m_NamHocData.LayDsNamHoc();

            DataTable dT = m_NamHocData.LayDsNamHoc();

            txtMaNH.DataBindings.Clear();
            txtMaNH.DataBindings.Add("Text", bS, "MaNH");

            txtTenNH.DataBindings.Clear();
            txtTenNH.DataBindings.Add("Text", bS, "TenNH");

            //bN.BindingSource = bS;
            dGV.DataSource = bS;
        }
        #endregion

        public void LuuNamHoc(String TenNH)
        {
            m_NamHocData.LuuNamHoc(TenNH);
        }

        public void UpdateNamHoc(String MaNH, String TenNH)
        {
            m_NamHocData.UpdateNamHoc(MaNH, TenNH);
        }

        public void DeleteNamHoc(String MaNH)
        {
            m_NamHocData.DeleteNamHoc(MaNH);
        }
    }
}
